import request from '../utils/request'

/**
 *
 * @param {Object} requestData - 商品id和数量
 * @returns
 */
export const addCart = (requestData) => {
  return request('/api/carts?', 'post', requestData)
}

/**
 *
 * @returns 购物车列表
 */
export const getCart = () => {
  return request('/api/carts?include=goods', 'get')
}

/**
 *
 * @param {Integer} id - 购物车id
 * @returns 改变数量
 */
export const changeCartNum = (id, num) => {
  return request(`/api/carts/${id}`, 'put', { num })
}

/**
 *
 * @param {Integer} id - 购物车id
 * @returns 删除
 */
export const deleteCart = (cart) => {
  return request(`/api/carts/${cart}`, 'delete')
}
/**
 *
* @param {Array} ids - 购物车选中id数组
 * @returns
 */
export const checkedCart = (ids) => {
  return request('/api/carts/checked', 'patch', ids)
}
